Fork me on GitHub

Including consoles in your posts

by Elliott Hauser

21 Jan 2014

You can include runnable code in your post by adding a Python console:

You'll need some include statements to do this. Include statements pull in code that starts and finishes the code block:

{% include python %}
for i in ["I", "love", "Python"]:
  print i
{% include endpython %}

If you want more than one console in your post, add id='uniqueID' to the includes statement. Each console needs a unique id value:

{% include python id='1'%
for i in ["I", "love", "Python", "too"]:
  print i
{% include endpython id='1' %}

A HUGE thanks to SILShacker and TA Grant McLendon for getting this working and looking pretty.

Elliott Hauser is a PhD Student in information science at UNC Chapel Hill. He's hacking education as one of the cofounders of Trinket.io. Find Elliott Hauser on Twitter, Github, and on the web.
comments powered by Disqus